package com.umakr.ax.oss.web;

import com.umakr.ax.core.base.AbstractController;
import com.umakr.ax.oss.service.StsServiceSample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

/**
 *
 * @author Mikey
 * @date 2018/1/11
 */
@Controller
@RequestMapping("/api/oss")
public class OssTokenController extends AbstractController{
    @Autowired
    StsServiceSample stsServiceSample;
    @RequestMapping("/token")
    @ResponseBody
    public Object ossToken(ModelMap modelMap,Long userId){
        return setSuccessModelMap(modelMap,stsServiceSample.getOssToken(userId));
    }

    @RequestMapping("/fileUpload")
    @ResponseBody
    public Object fileUpload(ModelMap modelMap, Long userId, @RequestParam("file") MultipartFile file, String filePath){
        return setSuccessModelMap(modelMap,stsServiceSample.fileUpload(userId,file,filePath));
    }
}
